﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;

namespace CoreSystem.Renderer
{
    public class UseClipping : IDisposable
    {
        // Fields
        private Graphics _g;
        private Region _old;

        // Methods
        public UseClipping(Graphics g, GraphicsPath path)
        {
            this._g = g;
            this._old = g.Clip;
            Region region = this._old.Clone();
            region.Intersect(path);
            this._g.Clip = region;
        }

        public UseClipping(Graphics g, Region region)
        {
            this._g = g;
            this._old = g.Clip;
            Region region2 = this._old.Clone();
            region2.Intersect(region);
            this._g.Clip = region2;
        }

        public void Dispose()
        {
            this._g.Clip = this._old;
        }
    }
}
